﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DDD4Fun.Observer
{
    public class BllData:ObservableImpl
    {
        int m_value;

        public int Value
        {
            set {
                m_value = value;
                base.NotifyObservers(m_value);
            }
            get
            {
                return m_value;
            }
        }
    }

    public class BllUI : IObserver
    {
        #region IObserver Members

        public void Notify(object anObject)
        {
            Console.WriteLine(anObject.ToString() + "is modified!!!!");
        }

        #endregion
    }

    public class BllUI2 : IObserver
    {
        #region IObserver Members

        public void Notify(object anObject)
        {
            if ((int)anObject > 50)
                Console.WriteLine(anObject.ToString() + "is modified from ui2!!!!");
        }

        #endregion
    }

    public class BllMain
    {
        public static void runmain()
        {
            /*数据更新之后通知ui更新*/
            /*怎么突然觉得有点像mvc..*/
            BllData data = new BllData();
            BllUI ui = new BllUI();
            BllUI2 ui2 = new BllUI2();
            data.Register(ui);
            data.Register(ui2);

            data.Value = 50;
            data.Value = 100;

        }
    }
}
